package com.ruoyi.web.cq;

import com.ruoyi.entity.domain.MsgLog;
import net.lz1998.cq.event.message.CQGroupMessageEvent;
import net.lz1998.cq.event.message.CQPrivateMessageEvent;

public class CQMessage {
    private Long messageId;
    private Long groupId;
    private Long userId;
    private String userName;
    private String messageBody;
    private String messageContent;
    private String subType;
    private String msgType;
    private String postType;

    public CQMessage(CQPrivateMessageEvent event) {
        this.messageId = Long.valueOf(event.getMessageId());
        this.groupId = 0l;
        this.userId = event.getUserId();
        this.userName = event.getSender().getNickname();
        this.messageBody = event.getMessage();
        this.messageContent = event.getRawMessage();
        this.subType = event.getSubType();
        this.msgType = event.getMessageType();
        this.postType = event.getPostType();
        System.out.println("[" + this.getGroupId() + "]<" + this.getUserName() + ">(" + this.getUserId() + ") : " + this.getMessageContent());
    }

    public CQMessage(CQGroupMessageEvent event) {
        this.messageId = Long.valueOf(event.getMessageId());
        this.userId = event.getUserId();
        this.groupId = event.getGroupId();
        this.userName = event.getSender().getNickname();
        this.messageBody = event.getMessage();
        this.messageContent = event.getRawMessage();
        this.subType = event.getSubType();
        this.msgType = event.getMessageType();
        this.postType = event.getPostType();
        System.out.println("[" + this.getGroupId() + "]<" + this.getUserName() + ">(" + this.getUserId() + ") : " + this.getMessageContent());
    }

    public Long getMessageId() {
        return messageId;
    }

    public Long getUserId() {
        return userId;
    }

    public Long getGroupId() {
        return groupId;
    }

    public String getUserName() {
        return userName;
    }

    public String getMessageBody() {
        return messageBody;
    }

    public String getMessageContent() {
        return messageContent;
    }

    public String getSubType() {
        return subType;
    }

    public String getMsgType() {
        return msgType;
    }

    public String getPostType() {
        return postType;
    }

    public MsgLog getMsgLog() {
        MsgLog msgLog = new MsgLog();
        msgLog.setMsgId(getMessageId());
        msgLog.setGroupId(getGroupId());
        msgLog.setUserId(getUserId());
        msgLog.setUserName(getUserName());
        msgLog.setMsgBody(getMessageBody());
        msgLog.setMsgContent(getMessageContent());
        msgLog.setSubType(getSubType());
        msgLog.setMsgType(getMsgType());
        msgLog.setPostType(getPostType());
        return msgLog;
    }
}
